package org.efssc
def build(apptype,appname,harborrepo,dev,tagname,Habor_passwd,Habor_username){
    if (apptype == "springboot"){
        //sh "cp devops/docker/${apptype}Dockerfile ${appname}/${appname}/ && cd ${appname}/${appname} &&  mvn clean package && docker build --build-arg appname=${appname} -t ${harborrepo}/${dev}/${appname}:${tagname} -f ${apptype}Dockerfile ."
        sh "cp devops/docker/${apptype}Dockerfile ${appname} && cd ${appname} &&  mvn clean package && docker build --build-arg appname=${appname} -t ${harborrepo}/${dev}/${appname}:${tagname} -f ${apptype}Dockerfile ."
        sh  "docker login -u ${Habor_username} -p ${Habor_passwd} ${harborrepo}"
        sh  "docker push ${harborrepo}/${dev}/${appname}:${tagname}"
    } else if(apptype == "npm"){
        sh "cp devops/docker/efssc.conf ${appname}/"
        sh "cp devops/docker/${apptype}Dockerfile ${appname}/ && cd ${appname} && npm run build && docker build -t ${harborrepo}/${dev}/${appname}:${tagname} -f ${apptype}Dockerfile ."
        sh  "docker login -u ${Habor_username} -p ${Habor_passwd} ${harborrepo}"
        sh  "docker push ${harborrepo}/${dev}/${appname}:${tagname}"
    }
}